﻿using System;
using System.Reflection;

namespace Fabrication.ValueProviders
{
    internal sealed class EnumProvider : IValueProvider
    {
        private Array enumValues;
        private bool hasValues;

        public void Initialize(PropertyInfo property)
        {
            enumValues = Enum.GetValues(property.PropertyType);
            hasValues = enumValues.Length > 0;
        }

        object IValueProvider.GetValue(object item)
        {
            return hasValues ? enumValues.GetValue(0) : null;
        }
    }
}